import { reqCategoryList,reqGetBannerList,reqFloorList} from "@/api/api"

const home ={
 //开启命名空间
  namespaced:true,
  actions:{
  //发起请求 三级联动数据
 async categoryList(context){  
  let res = await reqCategoryList()
  if (res.code == 200) {
    //返回了17条数据截取16条
    context.commit("CATEGORYLIST",res.data.slice(0,15))
  }
  },

  async getBannnerList(context){
    let res = await reqGetBannerList()
     if(res.code == 200){
      context.commit("GETBANNERLIST",res.data)
     } 
  },

  async getFloorList(context){
    let res = await reqFloorList()
    if (res.code) {
      context.commit("GEFLOORLIST",res.data)
    }
    
  }

}
,
mutations:{
  CATEGORYLIST(state,value){
    state.categoryList = value
  },
  GETBANNERLIST(state,value){
    state.bannerList = value
  },
  GEFLOORLIST(state,value){
    state.floorList = value
  }
},
state: {
  //三级联动数据
  categoryList:[],
  //轮播图数据
  bannerList:[],
  //floor
  floorList:[]
}
}

export default home